﻿package com.teaphy.coroutinecrawler.top_suspend

import kotlinx.coroutines.*

fun main() = runBlocking {

    println("start --> ")

    val job1 = launch(Dispatchers.IO) {
        println("job1 ---> start")
        delay(1000)
        println("job1 ---> end")
    }

    val job2 = launch(Dispatchers.IO) {
        println("job2 ---> start")
        delay(3000)
        println("job2 ---> end")
    }

    val job3 = launch(Dispatchers.IO) {
        println("job3 ---> start")
        delay(2000)
        println("job3 ---> end")
    }

    joinAll(job1, job2, job3)

    val job4 = launch(Dispatchers.IO) {
        println("job4 ---> start")
        delay(2000)
        println("job4 ---> end")
    }

    println("--> end")
}